import storage from '@/utils/storage'
const state = {
  authUser: storage.getItem('authUser'),
  token: storage.getItem('token'),
  oauthInfo: storage.getItem('oauthInfo'),
  oauthInfoLastTime: storage.getItem('oauthInfoLastTime')
}
const mutations = {
  SET_USER_DATA (state, payload) {
    state.authUser = payload
  },
  SET_TOKEN (state, payload) {
    state.token = payload
  },
  SET_OAUTH_INFO (state, payload) {
    state.oauthInfo = payload
  },
  SET_OAUTH_INFO_LAST_TIME (state, payload) {
    state.oauthInfoLastTime = payload
  }
}
const actions = {
  setUserData ({commit}, payload) {
    commit('SET_USER_DATA', payload)
  },
  setToken ({commit}, payload) {
    commit('SET_TOKEN', payload)
  },
  setOauthInfo ({commit}, payload) {
    commit('SET_OAUTH_INFO', payload)
  },
  setOauthInfoLastTime ({commit}, payload) {
    commit('SET_OAUTH_INFO_LAST_TIME', payload)
  }
}
const getters = {
  authUser: state => {
    return state.authUser
  },
  token: state => {
    return state.token
  },
  oauthInfo: state => {
    return state.token
  },
  oauthInfoLastTime: state => {
    return state.token
  }
}
export default {
  state, mutations, actions, getters
}
